package part19_状态模式_抽奖;

/**发放奖品的状态
 * @ClassName: DispenseState
 * @Author: AllenSun
 * @Date: 2020/3/9 21:27
 */
public class DispenseState extends State {

    //初始化时传入活动引用，发放就昂品后改变其状态
    RaffleActivity activity;

    public DispenseState(RaffleActivity activity) {
        this.activity = activity;
    }

    @Override
    public void deductMoney() {
        System.out.println("不能扣除积分");
    }

    @Override
    public boolean raffle() {
        System.out.println("不能抽奖");
        return false;
    }

    @Override
    public void despendePrize() {
        if(activity.getCount()>0){
            System.out.println("恭喜中奖了，奖品还有，可以给你");
            activity.setState(activity.getNoRaffleState());
        }else {
            System.out.println("很遗憾，奖品发送完了");
            activity.setState(activity.getDispenseOutState());
        }
    }
}
